﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YJKArchMethodLibrary.Utils
{
	public class ThicknessOfEdgeInfo : EdgeInfo
	{
		public double Thickness
		{
			get
			{
				return this.m_Thickness;
			}
			set
			{
				this.m_Thickness = value;
			}
		}

		public ElementId HostElementId
		{
			get
			{
				return this.m_HostElementId;
			}
			set
			{
				this.m_HostElementId = value;
			}
		}

		public ThicknessOfEdgeInfo(ThicknessOfEdgeInfo other) : base(other.StartPoint, other.EndPoint, other.Bulge)
		{
			this.m_Thickness = other.Thickness;
			this.m_HostElementId = other.m_HostElementId;
		}

		public ThicknessOfEdgeInfo(XYZ startPoint, XYZ endPoint, double bulge, double thickness, ElementId hostElementId) : base(EdgeInfo.Get2DXYZ(startPoint), EdgeInfo.Get2DXYZ(endPoint), bulge)
		{
			this.m_Thickness = thickness;
			this.m_HostElementId = hostElementId;
		}

		public ThicknessOfEdgeInfo(Curve curve, double thickness, ElementId hostElementId) : base(curve, false)
		{
			this.m_Thickness = thickness;
			this.m_HostElementId = hostElementId;
		}

		public void GetDoubleLine(ref EdgeInfo negativeLine, ref EdgeInfo positiveLine)
		{
			if (base.IsArc)
			{
				bool flag = true;
				if (base.Normal.IsAlmostEqualTo(-XYZ.BasisZ))
				{
					flag = false;
				}
				double num = -1.0;
				if (flag)
				{
					num = 1.0;
				}
				negativeLine = EdgeInfo.Offset(this, -this.m_Thickness / 2.0 * num);
				positiveLine = EdgeInfo.Offset(this, this.m_Thickness / 2.0 * num);
				return;
			}
			negativeLine = EdgeInfo.Offset(this, -this.m_Thickness / 2.0);
			positiveLine = EdgeInfo.Offset(this, this.m_Thickness / 2.0);
		}

		public void GetEndsLine(ref List<EdgeInfo> endsLineList)
		{
			if (Geometry.IsEqual(this.Thickness, 0.0))
			{
				return;
			}
			EdgeInfo edgeInfo;
			EdgeInfo edgeInfo2;
			if (base.IsArc)
			{
				bool flag = true;
				if (base.Normal.IsAlmostEqualTo(-XYZ.BasisZ))
				{
					flag = false;
				}
				double num = -1.0;
				if (flag)
				{
					num = 1.0;
				}
				edgeInfo = EdgeInfo.Offset(this, -this.m_Thickness / 2.0 * num);
				edgeInfo2 = EdgeInfo.Offset(this, this.m_Thickness / 2.0 * num);
			}
			else
			{
				edgeInfo = EdgeInfo.Offset(this, -this.m_Thickness / 2.0);
				edgeInfo2 = EdgeInfo.Offset(this, this.m_Thickness / 2.0);
			}
			EdgeInfo item = new EdgeInfo(edgeInfo.StartPoint, base.StartPoint, 0.0);
			endsLineList.Add(item);
			EdgeInfo item2 = new EdgeInfo(edgeInfo2.StartPoint, base.StartPoint, 0.0);
			endsLineList.Add(item2);
			EdgeInfo item3 = new EdgeInfo(edgeInfo.EndPoint, base.EndPoint, 0.0);
			endsLineList.Add(item3);
			EdgeInfo item4 = new EdgeInfo(edgeInfo2.EndPoint, base.EndPoint, 0.0);
			endsLineList.Add(item4);
		}

		private double m_Thickness;

		private ElementId m_HostElementId = ElementId.InvalidElementId;
	}
}
